<?php
class notenskala_model extends CI_Model {

	public function __construct()
	{
		$this->load->database();
	}
	
	public function get_notenskala($notencode)
	{
   		$this -> db -> from('notenskala');
		$this -> db -> where('NotenCode', $notencode);
		
		$query = $this -> db -> get();
		return $query->result_array();
	}
	
	public function set_notenskala($notenskala)
	{
		$i = 15;
		foreach($notenskala as $skala)
		{
			if ($skala != '')
			{
				$data = array(
					'NotenCode' => $this->input->post('notencode'),
					'Note' => $i,
					'AbProzent' => $skala
				);
				$this->db->insert('notenskala', $data);
			}
			$i--;
		}
		return true; 
	}
	
	public function delete_notenskala()
	{
		$notencode = $this->input->post('notencode');
		$this -> db -> where('NotenCode', $notencode);
		return $this -> db -> delete('notenskala'); 
	}
}